package controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import pojo.Memberinfo;
import service.GradeService;
import service.MemberService;

import javax.servlet.http.HttpServletRequest;
import java.util.Collection;
import java.util.List;

@Controller
@RequestMapping("/member")
public class MemberController {
    @Autowired
    private GradeService gradeService;
    @Autowired
    private MemberService memberService;
    @RequestMapping("/allMember")
    public String allMember(HttpServletRequest request,Model model){
        model.addAttribute("grade",gradeService.allGrade());
        request.setAttribute("ALL_USER_LIST",memberService.allMember());
        return "product";
    }
    @RequestMapping("/find")
    public String findMemberBySearch(String mname,int typeId,HttpServletRequest request,Model model){
        List<Memberinfo> list = memberService.findMemberBySearch(mname, typeId);
        request.setAttribute("ALL_USER_LIST",list);
        model.addAttribute("grade",gradeService.allGrade());
        return "product";
    }



}
